package io.xccit.race.service.impl;

import java.util.List;
import io.xccit.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import io.xccit.race.mapper.RaceRegionMapper;
import io.xccit.race.domain.RaceRegion;
import io.xccit.race.service.IRaceRegionService;

/**
 * 竞赛地区Service业务层处理
 * 
 * @author xccit
 * @date 2025-10-8
 */
@Service
public class RaceRegionServiceImpl implements IRaceRegionService 
{
    @Autowired
    private RaceRegionMapper raceRegionMapper;

    /**
     * 查询竞赛地区
     * 
     * @param id 竞赛地区主键
     * @return 竞赛地区
     */
    @Override
    public RaceRegion selectRaceRegionById(Long id)
    {
        return raceRegionMapper.selectRaceRegionById(id);
    }

    /**
     * 查询竞赛地区列表
     * 
     * @param raceRegion 竞赛地区
     * @return 竞赛地区
     */
    @Override
    public List<RaceRegion> selectRaceRegionList(RaceRegion raceRegion)
    {
        return raceRegionMapper.selectRaceRegionList(raceRegion);
    }

    /**
     * 新增竞赛地区
     * 
     * @param raceRegion 竞赛地区
     * @return 结果
     */
    @Override
    public int insertRaceRegion(RaceRegion raceRegion)
    {
        if (raceRegion.getDelFlag() == null) {
            raceRegion.setDelFlag("0");
        }
        raceRegion.setCreateTime(DateUtils.getNowDate());
        return raceRegionMapper.insertRaceRegion(raceRegion);
    }

    /**
     * 修改竞赛地区
     * 
     * @param raceRegion 竞赛地区
     * @return 结果
     */
    @Override
    public int updateRaceRegion(RaceRegion raceRegion)
    {
        raceRegion.setUpdateTime(DateUtils.getNowDate());
        return raceRegionMapper.updateRaceRegion(raceRegion);
    }

    /**
     * 批量删除竞赛地区
     * 
     * @param ids 需要删除的竞赛地区主键
     * @return 结果
     */
    @Override
    public int deleteRaceRegionByIds(Long[] ids)
    {
        return raceRegionMapper.deleteRaceRegionByIds(ids);
    }

    /**
     * 删除竞赛地区信息
     * 
     * @param id 竞赛地区主键
     * @return 结果
     */
    @Override
    public int deleteRaceRegionById(Long id)
    {
        return raceRegionMapper.deleteRaceRegionById(id);
    }

    /**
     * 查询所有省份
     * 
     * @return 省份列表
     */
    @Override
    public List<String> selectAllProvinces()
    {
        return raceRegionMapper.selectAllProvinces();
    }

    /**
     * 根据省份查询所有市
     * 
     * @param province 省份
     * @return 市列表
     */
    @Override
    public List<String> selectCitiesByProvince(String province)
    {
        return raceRegionMapper.selectCitiesByProvince(province);
    }

    /**
     * 根据省份和市查询所有县/区
     * 
     * @param province 省份
     * @param city 市
     * @return 县/区列表
     */
    @Override
    public List<String> selectDistrictsByProvinceAndCity(String province, String city)
    {
        return raceRegionMapper.selectDistrictsByProvinceAndCity(province, city);
    }
}
